public class LibrarySink extends Sink {
public LibrarySink(Sink next) { this.next = next; }
public Stack<Choicepoint> fishFor(String name, int arity, Compound term, int choice, Prolog prolog, Unifier unifier, int cutIndex, Stack<Conjunct> continuation, Stack<Choicepoint> choicepoints) {
Choicepoint choicepoint;
int height = choicepoints.height;
if(arity == 0 && name.equals("nl")) {
switch(choice) {
case 0: {
Compound t0 = new Compound("nl");
Compound t2 = new Compound("10");
Compound t1 = new Compound("write_character", t2);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t1);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 2 && name.equals("member")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t2 = new Compound(".", t1, t3);
Compound t0 = new Compound("member", t1, t2);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Variable t4 = new Variable("V2");
Compound t2 = new Compound(".", t3, t4);
Compound t0 = new Compound("member", t1, t2);
Compound t5 = new Compound("member", t1, t4);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t5);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 3 && name.equals("append")) {
switch(choice) {
case 0: {
Compound t1 = new Compound("[]");
Variable t2 = new Variable("V0");
Compound t0 = new Compound("append", t1, t2, t2);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t2 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t1 = new Compound(".", t2, t3);
Variable t4 = new Variable("V2");
Variable t6 = new Variable("V3");
Compound t5 = new Compound(".", t2, t6);
Compound t0 = new Compound("append", t1, t4, t5);
Compound t7 = new Compound("append", t3, t4, t6);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t7);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 3 && name.equals("revappend")) {
switch(choice) {
case 0: {
Compound t1 = new Compound("[]");
Variable t2 = new Variable("V0");
Compound t0 = new Compound("revappend", t1, t2, t2);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t2 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t1 = new Compound(".", t2, t3);
Variable t4 = new Variable("V2");
Variable t5 = new Variable("V3");
Compound t0 = new Compound("revappend", t1, t4, t5);
Compound t7 = new Compound(".", t2, t4);
Compound t6 = new Compound("revappend", t3, t7, t5);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t6);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 2 && name.equals("reverse")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t2 = new Variable("V1");
Compound t0 = new Compound("reverse", t1, t2);
Compound t4 = new Compound("[]");
Compound t3 = new Compound("revappend", t1, t4, t2);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t3);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 3 && name.equals("select")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t2 = new Compound(".", t1, t3);
Compound t0 = new Compound("select", t1, t2, t3);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Variable t4 = new Variable("V2");
Compound t2 = new Compound(".", t3, t4);
Variable t6 = new Variable("V3");
Compound t5 = new Compound(".", t3, t6);
Compound t0 = new Compound("select", t1, t2, t5);
Compound t7 = new Compound("select", t1, t4, t6);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t7);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 3 && name.equals("split")) {
switch(choice) {
case 0: {
Variable t2 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t1 = new Compound(".", t2, t3);
Compound t5 = new Compound("[]");
Compound t4 = new Compound("-", t5, t3);
Compound t0 = new Compound("split", t1, t2, t4);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t2 = new Variable("V0");
Variable t3 = new Variable("V1");
Compound t1 = new Compound(".", t2, t3);
Variable t4 = new Variable("V2");
Variable t7 = new Variable("V3");
Compound t6 = new Compound(".", t2, t7);
Variable t8 = new Variable("V4");
Compound t5 = new Compound("-", t6, t8);
Compound t0 = new Compound("split", t1, t4, t5);
Compound t9 = new Compound("\\=", t2, t4);
Compound t11 = new Compound("-", t7, t8);
Compound t10 = new Compound("split", t3, t4, t11);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t9, t10);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 3 && name.equals("sort")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t2 = new Variable("V1");
Variable t3 = new Variable("V2");
Compound t0 = new Compound("sort", t1, t2, t3);
Compound t5 = new Compound("[]");
Compound t4 = new Compound("qsort", t1, t2, t3, t5);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addQuerents(height-1, t4);
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 4 && name.equals("qsort")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Variable t4 = new Variable("V2");
Compound t2 = new Compound(".", t3, t4);
Variable t5 = new Variable("V3");
Variable t6 = new Variable("V4");
Compound t0 = new Compound("qsort", t1, t2, t5, t6);
Variable t8 = new Variable("V5");
Variable t9 = new Variable("V6");
Compound t7 = new Compound("partition", t1, t4, t3, t8, t9);
Variable t11 = new Variable("V7");
Compound t10 = new Compound("qsort", t1, t9, t11, t6);
Compound t13 = new Compound(".", t3, t11);
Compound t12 = new Compound("qsort", t1, t8, t5, t13);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height, t7, t10, t12);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t1 = new Variable("V0");
Compound t2 = new Compound("[]");
Variable t3 = new Variable("V1");
Compound t0 = new Compound("qsort", t1, t2, t3, t3);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
if(arity == 5 && name.equals("partition")) {
switch(choice) {
case 0: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Variable t4 = new Variable("V2");
Compound t2 = new Compound(".", t3, t4);
Variable t5 = new Variable("V3");
Variable t7 = new Variable("V4");
Compound t6 = new Compound(".", t3, t7);
Variable t8 = new Variable("V5");
Compound t0 = new Compound("partition", t1, t2, t5, t6, t8);
Variable t12 = new Variable("V6");
Compound t13 = new Compound("[]");
Compound t11 = new Compound(".", t12, t13);
Compound t10 = new Compound(".", t3, t11);
Compound t9 = new Compound("apply", t1, t10);
Variable t17 = new Variable("V7");
Compound t18 = new Compound("[]");
Compound t16 = new Compound(".", t17, t18);
Compound t15 = new Compound(".", t5, t16);
Compound t14 = new Compound("apply", t1, t15);
Compound t19 = new Compound(">=", t12, t17);
Compound t20 = new Compound("!");
Compound t21 = new Compound("partition", t1, t4, t5, t7, t8);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height, t9, t14, t19, t20, t21);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 1: {
Variable t1 = new Variable("V0");
Variable t3 = new Variable("V1");
Variable t4 = new Variable("V2");
Compound t2 = new Compound(".", t3, t4);
Variable t5 = new Variable("V3");
Variable t6 = new Variable("V4");
Variable t8 = new Variable("V5");
Compound t7 = new Compound(".", t3, t8);
Compound t0 = new Compound("partition", t1, t2, t5, t6, t7);
Compound t9 = new Compound("partition", t1, t4, t5, t6, t8);
if(unifier.unify(t0,term)) {
choicepoint = new Choicepoint(continuation,height, t9);
choicepoint.bindings = unifier.bound;
return new Stack<Choicepoint>(choicepoint,choicepoints);
}
break;
}
case 2: {
Variable t1 = new Variable("V0");
Compound t2 = new Compound("[]");
Compound t3 = new Compound("[]");
Compound t4 = new Compound("[]");
Compound t0 = new Compound("partition", t1, t2, t1, t3, t4);
if(unifier.unify(t0,term)) {
choicepoints.head.query = choicepoints.head.query.tail;
choicepoints.head.addBindings(unifier.bound);
return choicepoints;
}
break;
}
default: choicepoints.head.dead = true;
}
return choicepoints;
}
return next.fishFor(name,arity,term,choice,prolog,unifier,cutIndex,continuation,choicepoints);
}
}
